/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package artaza.service;

import artaza.clasesdao.EventoDAO;
import artaza.persistencia.Evento;
import com.google.appengine.api.datastore.Key;
import java.util.Collection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.stereotype.Service;

/**
 *
 * @author AGM
 */

@Service
public class EventoServiceImpl implements EventoService {

    private EventoDAO eventoDAO;
    
    @Autowired
    @Required
    public void setEventoDAO(final EventoDAO eventoDAO) {
        this.eventoDAO = eventoDAO;
    }

    @Override
    public void create(final Evento evento){
    eventoDAO.insert(evento);

    }

    @Override
    public void remove (final Key id_evento){
    Evento evento=eventoDAO.findByPK(Evento.class,id_evento);
    eventoDAO.remove(evento);
    }

    @Override
    public Collection<Evento> getAlleventos(){
      return eventoDAO.getAll(Evento.class);
    }

    @Override
    public Evento findByPK(Key id_evento){
       Evento e = eventoDAO.findByPK(Evento.class,id_evento);
       return e;
    }

    @Override
    public void update(Evento e){
         eventoDAO.update(e);
    }
}
